package com.group8.gm;

import java.util.Vector;

import com.group8.ge.GameObject;
import com.group8.ge.Noodle;

public class NoodleManager  implements Runnable{
	private int x;
	private int y;
	private int powerUpId;
	private double speed;
	private double hop_dist;
	private Noodle noodle;
	GameController gc;
	
	public NoodleManager(GameController gc){
		this.gc = gc;
		noodle = new Noodle(gc);
		
	}
	
	public Noodle getNoodle(){
		return noodle;
		
	}
	public void updateNoodle() {
		
	}

	/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
	@Override
	public void run() {
		double time = 0;
		while(true) {
			if(noodle.getY()<640)
			while(time <= noodle.getSpeed() || time<noodle.getHop_dist()){
				noodle.setY(noodle.getY()-1 );
				time = time+1;
				gc.updateUI();
				try {
					Thread.sleep(3);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				gc.updateUI();
			}
			
			while(!gc.collisionCheckWithPlates(noodle, gc.getDownPlates(noodle.getY()))){
				noodle.setY(noodle.getY()+1);
				try {
					Thread.sleep(3);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				gc.updateUI();
			}
			try {
				Thread.sleep(10);
				
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			time = 0;
		}
			
		
	}
}
